﻿@model Fcom.VNInsurance.Web.Models.CompanyProductLang
@{
    ViewBag.Title = "EditCompanyProduct";
    Layout = "~/Views/Shared/_CpanelLayout.cshtml";
    var CompanyInfo = (Fcom.VNInsurance.Web.Models.CompanyLang)ViewBag.CompanyInfo;
    var langInfo = (Fcom.VNInsurance.Web.Models.Language)ViewBag.Lang;
}
<script src="@Url.Content("~/Content/tinymce/tinymce.min.js")"></script>
<link rel="stylesheet" href="@Url.Content("~/Content/treeview/jquery.treeview.css")" />
<link href="@Url.Content("~/Content/contextmenu/jquery.contextMenu.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Content/treeview/jquery.treeview.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/contextmenu/jquery.ui.position.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/contextmenu/jquery.contextMenu.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {

        $(".fancybox-close").click(function () {
            $("#fancy").fadeOut();
        });



        $("#btnupload").click(function () {
            $("#fancy").fadeIn();
            $("#currenttiny").html("ProductImage");
            return false;
        });


    });

    jQuery.fn.center = function () {
        this.css("position", "absolute");
        this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) +
                                                $(window).scrollTop()) + "px");
        this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) +
                                                $(window).scrollLeft()) + "px");
        return this;
    }

    function ajaxdbSelect(sfile) {
        currentSkfile = $(sfile);
        $(".skselected").removeClass("skselected");
        if (!currentSkfile.hasClass("skselected")) {
            currentSkfile.addClass("skselected");
        }
    }
    function ajaxSelect(sfile) {
        //if ($('.mydivclass').length) {
        currentSkfile = $(sfile);
        if (currentSkfile.hasClass("skselected")) {
            currentSkfile.removeClass("skselected");
        }
        else {
            currentSkfile.addClass("skselected");
        }
    }

    function ajaxRfiles(stringpath) {
        $.getJSON("/File/ReadFiles", { folderPath: stringpath }, function (rvdata) {
            htmlcode = "";

            var currentFolder = $(".skselected-folder").attr("rel");
            $("#skFolderContent").html("<center><img src='/Content/loading.gif'></center>");
            $(rvdata).each(function () {
                htmlcode += "<div class='skfile' onclick=\"return ajaxSelect(this)\;\" rel='" + $(this).attr("Name") + "'>";
                htmlcode += "<div class='skfileicon'>";
                if ($(this).attr("isImage")) {
                    htmlcode += "<img src='" + "/" + currentFolder + "/" + $(this).attr("Name") + "'   class='skfileicon-image'/>";
                }
                else {

                }
                htmlcode += "</div>";
                htmlcode += "<div class='skfilename'><p>" + $(this).attr("Name") + "</p></div>";
                htmlcode += "</div>";
            });
            $("#skFolderContent").html(htmlcode);
        });
    }
    function ajaxRtree(mtree) {
        $(".skselected-folder").removeClass("skselected-folder");

        $(mtree).addClass("skselected-folder");
        currentFolder = $(mtree);
        var uploader = new qq.FileUploader({
            element: document.getElementById('file-uploader'),
            multiple: false,
            allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
            params: { FolderPath: currentFolder.attr("rel") },
            multiple: true,
            acceptFiles: "image/*",
            action: '@Url.Action("Upload", "File")',
                onComplete: function (id, fileName, responseJSON) {
                    if (uploader.getInProgress() > 0) {
                        return;
                    }
                    else {
                        $("#refresh-listfile").click();
                    }
                }
            });
            var thispath = $(mtree).attr("rel");
            ajaxRfiles(thispath);
            subul = currentFolder.next();
            parentFolder = currentFolder.parent().parent().prev();

            $.getJSON("/File/ReadFolder", { folderPath: thispath }, function (rvdata) {

                subul.addClass("closed");
                subul.html(""); htmlcode = "";
                $(rvdata).each(function () {
                    if (parseInt($(this).attr("hasFiles")) > 0 ? "class=closed" : "") {
                        htmlcode += "<li class=closed><span class='folder' onclick=\"return ajaxRtree(this)\;\" rel='" + currentFolder.attr("rel") + "/" + $(this).attr("Name") + "'>";
                        htmlcode += $(this).attr("Name");
                        htmlcode += "</span><ul></ul></li>";
                    } else {
                        htmlcode += "<li><span class='folder'  onclick=\"return ajaxRtree(this)\;\" rel='" + currentFolder.attr("rel") + "/" + $(this).attr("Name") + "'>";
                        htmlcode += $(this).attr("Name");
                        htmlcode += "</span></li>";
                    }
                });
                subul.html(htmlcode);
            });
        }
        function ajaxReadFolder(foldername) {

            return false;
        }
        $(document).ready(function (e) {
            $(function () {
                $.contextMenu({
                    selector: '.skfile',
                    callback: function (key, options) {
                        var currentFileName = $(this).attr("rel");
                        var currentFolder = $(".skselected-folder").attr("rel");
                        var currentFile = $(this);
                        var currentPath = currentFolder + "/" + currentFileName;
                        if (key == "edit") {
                            $("#editFile").css("display", "block");
                            $(".edNewFileName").val(currentFileName);
                            $(".edFileName").html(currentFileName);
                        }
                        else if (key == "insert") {

                            var imagepath = "/" + currentFolder + "/" + currentFileName;

                            $("#fancy").fadeOut();
                            if ($("#currenttiny").html() == "ProductImage") {
                                $("#ProductImage").val(imagepath);
                                $("#imgshow").attr("src", imagepath);
                            }
                            else {

                                tinymce.get($("#currenttiny").html()).selection.setContent("<img src='" + imagepath + "'/>");
                            }

                        }
                        else if (key == 'delete') {
                            //do some thing to delete file.
                            filecount = $(".skselected").length;
                            var msgtext = "tập tin " + currentFileName;

                            if (filecount > 0) {
                                msgtext = filecount + " tập tin đã chọn";
                                if (confirm("Bạn có muốn xóa " + msgtext + " ?")) {
                                    $(".skselected").each(function () {
                                        var currentFileSeleted = $(this);
                                        currentFileSeletedFilename = currentFileSeleted.attr("rel");
                                        pathtodelete = currentFolder + "/" + currentFileSeletedFilename;
                                        $.getJSON("/File/ajaxDeleteFile", { spath: pathtodelete }, function (rvdata) {
                                            if (rvdata.status == true) {
                                                currentFileSeleted.remove();
                                            }
                                            else {
                                                alert(rvdata.msg);
                                            }
                                        });
                                    });
                                }
                            }
                            else {
                                if (confirm("Bạn có muốn xóa " + msgtext + " ?")) {
                                    //do something to deletefile..

                                    pathtodelete = currentFolder + "/" + currentFileName;
                                    //ajaxDeleteFile
                                    $.getJSON("/File/ajaxDeleteFile", { spath: pathtodelete }, function (rvdata) {
                                        if (rvdata.status == true) {
                                            currentFile.remove();
                                        }
                                        else {
                                            alert(rvdata.msg);
                                        }
                                    });
                                }
                            }
                        }
                    },
                    items: {
                        "edit": { name: "Rename", icon: "edit", accesskey: "e" },
                        "insert": { name: "Insert", icon: "add" },
                        "delete": { name: "Delete", icon: "delete" },
                        "sep1": "---------",
                        "quit": { name: "Quit", icon: "quit" }
                    }
                });
            });
            $("#editFile").center();
            $("#browser").treeview();
            $("#edSave").click(function () {
                var currentFolder = $(".skselected-folder").attr("rel");
                var path = $(".edFileName").html();
                var newfile = $(".edNewFileName").val();
                $.getJSON("/File/ajaxRenameFile", { spath: currentFolder + "/" + path, foder: currentFolder, newfilename: newfile }, function (rvdata) {
                    if (rvdata.status == true) {
                        ajaxRfiles(currentFolder);
                        $("#editFile").css("display", "none");
                    }
                    else {
                        alert(rvdata.msg);
                    }
                });
            });

            $("#can").click(function () { $("#editFile").css("display", "none"); });
            $("#refresh-listfile").click(function () {
                var currentFolder = $(".skselected-folder").attr("rel");
                ajaxRfiles(currentFolder);
                return false;
            });

        });

        tinymce.init({
            mode: "exact",
            elements: "Benefit",
            autosave_restore_when_empty: false,
            plugins: [
                "advlist autolink autosave link image lists charmap print preview hr anchor pagebreak spellchecker",
                "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
                "table contextmenu directionality emoticons template textcolor paste fullpage textcolor"
            ],

            toolbar1: "newdocument fullpage | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | styleselect formatselect fontselect fontsizeselect",
            toolbar2: "cut copy paste | searchreplace | bullist numlist | outdent indent blockquote | undo redo | link unlink anchor insertimg media code | inserttime preview | forecolor backcolor",
            toolbar3: "table | hr removeformat | subscript superscript | charmap emoticons | print fullscreen | ltr rtl | spellchecker | visualchars visualblocks nonbreaking template pagebreak restoredraft"
        , setup: function (ed) {
            // Add a custom button
            ed.addButton('insertimg', {
                title: 'Insert Images',
                image: '/content/images/insert-img.png',
                onclick: function () {
                    // Add you own code to execute something on click
                    $("#fancy").fadeIn();
                    $("#currenttiny").html("Benefit");
                    ed.focus();
                    //ed.selection.setContent('Hello world!');
                }
            });
        },
            style_formats: [
                  { title: 'Bold text', inline: 'b' },
                  { title: 'Red text', inline: 'span', styles: { color: '#ff0000' } },
                  { title: 'Red header', block: 'h1', styles: { color: '#ff0000' } },
                  { title: 'Example 1', inline: 'span', classes: 'example1' },
                  { title: 'Example 2', inline: 'span', classes: 'example2' },
                  { title: 'Table styles' },
                  { title: 'Table row 1', selector: 'tr', classes: 'tablerow1' }
            ],
            relative_urls: false,
            remove_script_host: false,
            convert_urls: true,
        });
        tinymce.init({
            mode: "exact",
            elements: "Moreinfo",
            autosave_restore_when_empty: false,
            plugins: [
               "advlist autolink autosave link image lists charmap print preview hr anchor pagebreak spellchecker",
               "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
               "table contextmenu directionality emoticons template textcolor paste fullpage textcolor"
            ],

            toolbar1: "newdocument fullpage | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | styleselect formatselect fontselect fontsizeselect",
            toolbar2: "cut copy paste | searchreplace | bullist numlist | outdent indent blockquote | undo redo | link unlink anchor insertimg media code | inserttime preview | forecolor backcolor",
            toolbar3: "table | hr removeformat | subscript superscript | charmap emoticons | print fullscreen | ltr rtl | spellchecker | visualchars visualblocks nonbreaking template pagebreak restoredraft"
        , setup: function (ed) {
            // Add a custom button
            ed.addButton('insertimg', {
                title: 'Insert Images',
                image: '/content/images/insert-img.png',
                onclick: function () {
                    // Add you own code to execute something on click
                    $("#fancy").fadeIn();
                    $("#currenttiny").html("Moreinfo");
                    ed.focus();
                    //ed.selection.setContent('Hello world!');
                }
            });
        },
            style_formats: [
                  { title: 'Bold text', inline: 'b' },
                  { title: 'Red text', inline: 'span', styles: { color: '#ff0000' } },
                  { title: 'Red header', block: 'h1', styles: { color: '#ff0000' } },
                  { title: 'Example 1', inline: 'span', classes: 'example1' },
                  { title: 'Example 2', inline: 'span', classes: 'example2' },
                  { title: 'Table styles' },
                  { title: 'Table row 1', selector: 'tr', classes: 'tablerow1' }
            ],
            relative_urls: false,
            remove_script_host: false,
            convert_urls: true,
        });
        tinymce.init({
            mode: "exact",
            elements: "Intro",
            autosave_restore_when_empty: false,
            plugins: [
               "advlist autolink autosave link image lists charmap print preview hr anchor pagebreak spellchecker",
               "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
               "table contextmenu directionality emoticons template textcolor paste fullpage textcolor"
            ],

            toolbar1: "newdocument fullpage | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | styleselect formatselect fontselect fontsizeselect",
            toolbar2: "cut copy paste | searchreplace | bullist numlist | outdent indent blockquote | undo redo | link unlink anchor insertimg media code | inserttime preview | forecolor backcolor",
            toolbar3: "table | hr removeformat | subscript superscript | charmap emoticons | print fullscreen | ltr rtl | spellchecker | visualchars visualblocks nonbreaking template pagebreak restoredraft"
            , setup: function (ed) {
                // Add a custom button
                ed.addButton('insertimg', {
                    title: 'Insert Images',
                    image: '/content/images/insert-img.png',
                    onclick: function () {
                        // Add you own code to execute something on click
                        $("#fancy").fadeIn();
                        $("#currenttiny").html("Intro");
                        ed.focus();
                        //ed.selection.setContent('Hello world!');
                    }
                });
            },
            style_formats: [
                  { title: 'Bold text', inline: 'b' },
                  { title: 'Red text', inline: 'span', styles: { color: '#ff0000' } },
                  { title: 'Red header', block: 'h1', styles: { color: '#ff0000' } },
                  { title: 'Example 1', inline: 'span', classes: 'example1' },
                  { title: 'Example 2', inline: 'span', classes: 'example2' },
                  { title: 'Table styles' },
                  { title: 'Table row 1', selector: 'tr', classes: 'tablerow1' }
            ],
            relative_urls: false,
            remove_script_host: false,
            convert_urls: true,

        });
        tinymce.init({
            mode: "exact",
            elements: "Condition",
            autosave_restore_when_empty: false,
            plugins: [
               "advlist autolink autosave link image lists charmap print preview hr anchor pagebreak spellchecker",
               "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
               "table contextmenu directionality emoticons template textcolor paste fullpage textcolor"
            ],

            toolbar1: "newdocument fullpage | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | styleselect formatselect fontselect fontsizeselect",
            toolbar2: "cut copy paste | searchreplace | bullist numlist | outdent indent blockquote | undo redo | link unlink anchor insertimg media code | inserttime preview | forecolor backcolor",
            toolbar3: "table | hr removeformat | subscript superscript | charmap emoticons | print fullscreen | ltr rtl | spellchecker | visualchars visualblocks nonbreaking template pagebreak restoredraft"
                , setup: function (ed) {
                    // Add a custom button
                    ed.addButton('insertimg', {
                        title: 'Insert Images',
                        image: '/content/images/insert-img.png',
                        onclick: function () {
                            // Add you own code to execute something on click
                            $("#fancy").fadeIn();
                            $("#currenttiny").html("Condition");
                            ed.focus();
                            //ed.selection.setContent('Hello world!');
                        }
                    });
                },
            style_formats: [
                  { title: 'Bold text', inline: 'b' },
                  { title: 'Red text', inline: 'span', styles: { color: '#ff0000' } },
                  { title: 'Red header', block: 'h1', styles: { color: '#ff0000' } },
                  { title: 'Example 1', inline: 'span', classes: 'example1' },
                  { title: 'Example 2', inline: 'span', classes: 'example2' },
                  { title: 'Table styles' },
                  { title: 'Table row 1', selector: 'tr', classes: 'tablerow1' }
            ],
            relative_urls: false,
            remove_script_host: false,
            convert_urls: true,

        });
    //Condition

</script>
<style>
    input[type="text"] {
        font-size:12px;
    }
    .title {
        font-family:Tahoma;
        font-size:14px;
        color:blue;
    }
    .textbox {
        float:left;
        width:300px;
        margin-bottom:5px;
    }
    .error {
    text-transform:none;
    color:red;
    padding-top:5px;
    margin-left:10px;
}
    .imgshow img{
    max-width:600px;
    max-height:200px;
    }
    .erro {
        color:red;
    }
    #dm {
        height:30px;
    }
    #skyFileManger {
    width: 960px;
    margin: 0px auto;
    min-height: 300px;
    border: 1px solid #E4E4E4;
    padding: 3px;
}

#skFolder {
    width: 200px;
    float: left;
    height: 400px;
    overflow: auto;
}

#skFolderContent {
    width: 750px;
    float: left;
    background: whiteSmoke;
    height: 500px;
    overflow: auto;
    padding: 5px;
}

.skfile {
    width: 100px;
    height: 140px;
    border: 2px solid #ccc;
    padding: 5px;
    background: #FFF;
    float: left;
    margin: 10px;
    cursor: pointer;
}

    .skfile:hover {
        border: 2px solid #ddeff8;
        background: #f2f9fc;
    }

.skfilename {
    padding: 2px;
    text-align: center;
    margin-top: 10px;
}

.skselected {
    background: #ffdd88;
    border: 2px solid #ffbb00;
}

    .skselected:hover {
        background: #ffdd88;
        border: 2px solid #ffbb00;
    }

.skselected-folder {
    color: #000;
    font-weight: bold;
}

.skupload {
    padding-top: 5px;
}

.skselected-folder:hover {
    color: #000 !important;
}

.skfileicon-image {
    max-width: 90px;
    max-height: 100px;
}

.skfileicon {
    text-align: center;
    min-width: 90px;
    min-height: 60px;
}

#editFile {
    width: 300px;
    background: #3F3F49;
    padding: 10px 0px;
}

    #editFile label {
        font-weight: bold;
        color: White;
        padding-bottom: -20px;
        padding-left: 15px;
    }

    #editFile input {
        width: 100px;
        height: 35px;
        padding-right: 10px;
    }

.edFileName {
    color: White;
    margin: 10px 10px 0px 10px;
    display: block;
}

#editFile input.edNewFileName {
    width: auto;
    height: 5px;
    padding-right: 10px;
    margin-top: 10px;
    margin-left: 10px;
}

#editFile input#edSave {
    margin-left: 10px;
    margin-top: 5px;
}
  
</style>
<div class="container" style="padding:10px;">
    @using (Html.BeginForm()) { 
           <fieldset>
                 <legend >Sửa sản phẩm công ty: @Model.DisplayName</legend>
               @Html.HiddenFor(m=>m.CProductID)
            </fieldset>
        <div class="form-group">
            Công ty <img src="@Url.Content("~/Content/images/CompanyLogo/"+CompanyInfo.CompanyLogo)" width="200px" height="100px"/>
        </div>
        <div class="form-group">
            <label for="txttitle">Hình sản phẩm (*)</label><br />
          
            <img style="width:200px; max-height:150px" src="@Url.Content("~"+Model.ProductImage)" id="imgshow"/><br />
            @Html.TextBoxFor(m => m.ProductImage, new { @readonly=true})
            <input type="button" id="btnupload" value="Chọn hình sản phẩm"/> hoặc  Để  trống sử dụng logo công ty
          </div>
                 <div class="form-group">
            <label for="txttitle">Tên sản phẩm (*)</label>
            @Html.TextBoxFor(m => m.DisplayName, new {@class="form-control" })
          </div>
          <div class="form-group">
            <label for="txttitle">Quyền lợi (*)</label>
            @Html.TextAreaFor(m => m.Benefit, new {@class="form-control",rows=8 })
          </div>
        <div class="container">
            <div class="col-lg-6">

                 <div class="form-group">
            <label for="txttitle">Quyền lợi và tính năng (*)</label>
            @Html.TextAreaFor(m => m.Moreinfo, new {@class="form-control",rows=8})
          </div>

            </div>
            <div class="col-lg-6">

                 <div class="form-group">
            <label for="txttitle">Điều kiện tham gia (*)</label>
            @Html.TextAreaFor(m => m.Condition, new {@class="form-control",rows=8 })
          </div>

            </div>
        </div>
      
         <div class="form-group">
            <label for="txttitle">Giới thiệu (*)</label>
            @Html.TextAreaFor(m => m.Intro, new {@class="form-control",rows=20  })
          </div>
        <div class="form-group">
            <label for="txttitle">Số tiền bảo hiểm (*)</label>
            @Html.TextBoxFor(m => m.InsuranceMoney) VND
          </div>
        <div class="form-group">
            <label for="txttitle">Phí bảo hiểm (*)</label>
            @Html.TextBoxFor(m => m.OneFare) VND          </div>
        <div class="form-group">
            <label for="txttitle">Bật/tắt (*)</label>
            @Html.CheckBox("Enable",Model.CompanyProduct.Enable)
          </div>
        <div class="form-group">
            <label for="txttitle">Thời hạn đóng phí (*)</label>
            @Html.TextBoxFor(m=>m.Paytem)
          </div>
         <div class="form-group">
            <label for="txttitle">Số tiền tiết kiệm (*)</label>
            @Html.TextBoxFor(m=>m.Guaranteed)
          </div>
         <div class="form-group">
            <label for="txttitle">Số tiền tiết kiệm mong đợi (*)</label>
            @Html.TextBoxFor(m=>m.Guaranteed)
          </div>
         <div class="form-group">
            <label for="txttitle">Phí góp (*)</label>
            @Html.TextBoxFor(m=>m.Premiumtopay)
          </div>
          <button type="submit" class="btn btn-success">Lưu</button>
    }

</div>
